import request from '@/utils/request'

export function fetchList(query, module) {
  return request({
    url: '/api/' + module + '/getlist',
    method: 'post',
    data: query
  })
}
export function fetchTree(query, url) {
  return request({
    url: url,
    method: 'post',
    data: query
  })
}
export function fetchDict(name) {
  const listQuery = {
    page_no: 1,
    limit: 100,
    sort: 'id',
    where: { and: [{ field: 'name', operator: '=', value: name }] }
  }
  return request({
    url: '/api/sl_valdict/getlist',
    method: 'post',
    data: listQuery
  })
}
export function fetchArticle(id) {
  return request({
    url: '/vue-element-admin/article/detail',
    method: 'get',
    params: { id }
  })
}

export function fetchPv(pv) {
  return request({
    url: '/vue-element-admin/article/pv',
    method: 'get',
    params: { pv }
  })
}

export function createArticle(data, module) {
  return request({
    url: '/api/' + module + '/save',
    method: 'post',
    data
  })
}
export function delArticle(data, module) {
  return request({
    url: '/api/' + module + '/del',
    method: 'post',
    data
  })
}
export function updateArticle(data, module) {
  return request({
    url: '/api/' + module + '/save',
    method: 'post',
    data
  })
}
